

public class StringDemo1 {

    public static void main(String[] args) {

        String str =  "abc";
        String str2 = "abc";
        System.out.println(str==str2);

        //字符数组创建String变量
        char[] chs = {'a','b','c'};
        String str3 = new String(chs);
        System.out.println(str3);

        //字符串作为参数创建字符串对象
        String str4 = new String("abc");
        System.out.println(str4);

        //通过字节数组创建字符串对象
        byte[] b = {97,98,99};
        String str5 = new String(b);
        System.out.println(str5);

    }
}
